<template>
  <div id="setup-page" :style="{
    width:'100%',
    height: (this.getWinSize().height-34-this.getSafeArea().top)+'px',
    paddingTop:(this.getSafeArea().top+34)+'px'
  }">
    <div class="page-title" :style="{
      top:(this.getSafeArea().top)+'px'
    }">
      <div id="back-button" @click="$router.push('/MemberHome')">
        <i href="javascript:void(0)" class="el-icon-arrow-left"></i>
      </div>
      <span>设置</span>
    </div>
    <div class="form">
      <div class="item" @click="$router.push('/MemberInfo')">
        <div class="left">
          <i class="icon iconfont icon-gerenziliao"></i>
          <span>资料修改</span>
        </div>
        <div class="right">
          <i class="el-icon-arrow-right"></i>
        </div>
        <div class="c"></div>
      </div>


      <div class="item" @click="$router.push('MemberChangePassword')">
        <div class="left">
          <i class="icon iconfont icon-genggaimima"></i>
          <span>密码修改</span>
        </div>
        <div class="right">
          <i class="el-icon-arrow-right"></i>
        </div>
        <div class="c"></div>
      </div>

      <div class="item" @click="$router.push('MemberAddressList')">
        <div class="left">
          <i class="icon iconfont icon-genggaimima"></i>
          <span>地址管理</span>
        </div>
        <div class="right">
          <i class="el-icon-arrow-right"></i>
        </div>
        <div class="c"></div>
      </div>


      <div class="item" @click="checkAppVersion">
        <div class="left">
          <i class="icon iconfont icon-banben"></i>
          <span v-text="'当前版本('+appVersion+')'"></span>
        </div>
        <div class="right">
          <i class="el-icon-arrow-right"></i>
        </div>
        <div class="c"></div>
      </div>



      <div class="c"></div>
    </div>


    <div class="page-bottom">
      <el-button type="danger" :loading="loading" :disabled="loading" size="medium" style="width: 90%" @click="loginOut">退出登录</el-button>
    </div>
  </div>
</template>

<script>
export default {
  name: "Setup",
  data:function () {
    return {
      userInfo:{
        icon:'',
        nickname:'',
      },
      loading:false
    }
  },
  mounted() {
    this.getDetail()
  },
  methods:{
    getDetail:function () {
      let $this = this
      $this.MyRequest($this.ApiDoNameShop + 'Shop/info', {}, function (data) {
          $this.userInfo.nickname = data.clerk.nickname
          $this.userInfo.icon = data.clerk.icon
          $this.$forceUpdate()
        }, function (msg) {
        $this.$message.error(msg)
        // $this.form.password = ''
      })
    },
    checkAppVersion:function () {
      let $this=this
      var platform='Android'
      if (typeof api!=='undefined' && api.deviceModel){
        platform=api.deviceModel.indexOf('iPhone')>-1?'iPhone':'Android'
      }
      $this.MyRequest($this.ApiDoNameShop + 'Public/checkAppVersion', {appVersion:this.appVersion,platform:platform}, function (url) {
        if (url.indexOf('http')>-1){
          $this.$confirm('有新的版本是否前往下载?', '系统提示', {
            customClass:'my-confirm-box',
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            backType: 'warning'
          }).then(() => {
          }).then(() => {
            var param = {Url:url};
            jumpbrowser.jumpBrowser(param, function(ret, err){
            });
          }).catch(() => {

          });
        }else{
          $this.$message.success('当前已是最新版本')
        }
        $this.$forceUpdate()
      }, function (msg) {
        $this.loading=false
        // $this.$message.error(msg)
      })
    },
    loginOut:function () {
      let $this=this
      this.$confirm('您确认要进行该操作吗, 是否继续?', '系统提示', {
        customClass:'my-confirm-box',
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        backType: 'warning'
      }).then(() => {

        $this.MyRequest($this.ApiDoNameAuth + 'User/loginOut', {}, function (data) {
          $this.loading=false
          $this.$forceUpdate()
        }, function (msg) {
          $this.loading=false
          // $this.$message.error(msg)
        })
        $this.CurrUser.setCache(null)
        $this.$router.push("/Login")
      }).catch(() => {

      });
    },
  }
}
</script>

<style scoped>

</style>
